home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wtek0693.zip / OOPALLEY.ZIP / XSORTCLT.CPP < prev    next >
C/C++ Source or Header  |  1993-03-22  |  1KB  |  38 lines

  1. #include "point.h"
  2. #include "sortcltn.h"
  3. #include "set.h"
  4.  
  5. main()
  6. {
  7.     cout << "\nTest class SortedCltn\n";
  8.     Point A(1,1);               // create Point, A
  9.     Point B(1,2);
  10.     Point C(1,3);
  11.     Point D(1,3);
  12.     Point E(1,4);
  13.  
  14.     SortedCltn s(8);            // create SortedCltn, s
  15.     SortedCltn t(8);
  16.                                 
  17.     s.add(A);                   // add Points to s 
  18.     s.add(B);                   // points are sorted
  19.     s.add(C);                   // as they are added
  20.     s.add(D);
  21.     s.add(E);
  22.     cout << "s = " << s << "\n"; // print s contents
  23.  
  24.     t.add(E);                   // add Points to t
  25.     t.add(D);                   // in different order
  26.     t.add(C);
  27.     t.add(B);
  28.     t.add(A);
  29.     cout << "s==t: " << (s==t) << "\n"; // equality test
  30.                                 // collections compare equal 
  31.                                 // despite order in which                                
  32.                                 // elements were added
  33.  
  34.     Set st = s.asSet();         // Sets eliminate duplicates
  35.     cout << "s.asSet(): " << st << "\n";
  36.     cout << "st.asSortedCltn(): " << st.asSortedCltn() << "\n";
  37. }
  38.